package cn.iot.netty.util;

/**
 * 指令类型
 */
public enum InstructTypeConstant {

    E_MAIN_GATE_NO("1", "电-合总闸"),
    E_MAIN_GATE_OFF("2", "电-拉总闸"),
    E_A_GATE_NO("3", "电-A合总闸"),
    E_A_GATE_OFF("4", "电-A拉总闸"),
    E_B_GATE_NO("5", "电-B合总闸"),
    E_B_GATE_OFF("6", "电-B拉总闸"),
    E_MAIN_PARSM_INFO("7", "获取电表参数信息"),
    E_A_POWER_SETUP("8", "下发A路功率设置"),
    E_A_WEEK_SETUP("9", "A路周休特征字设置-一周"),
    E_B_WEEK_SETUP("10", "B路周休特征字设置-一周"),
    E_A_TIME_WORK_SETUPA("11", "A路工作日时段控制设置"),
    E_A_TIME_REST_SETUPA("12", "A路休息日时段控制设置"),
    E_B_TIME_WORK_SETUPA("13", "B路工作日时段控制设置"),
    E_B_TIME_REST_SETUPA("14", "B路休息日时段控制设置"),
    E_RECHARGE_SETUPA("15", "电表充值"),
    E_BALANCE_SETUPA("16", "查询电表金额"),
    E_OPEN_ACCOUNT("17", "电表重新开户"),
    W_GATE_NO("100", "水-开阀"),
    W_GATE_OFF("101", "水-关阀"),
    W_SEARCH_INFO("102", "水-查询水表信息");


    private String key;
    private String value;

    InstructTypeConstant(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static InstructTypeConstant getByKey(String key) {
        if (null == key) {
            return null;
        }
        for (InstructTypeConstant status : InstructTypeConstant.values()) {
            if (status.getKey().equals(key)) {
                return status;
            }
        }
        return null;
    }

    public static InstructTypeConstant getByValue(String value) {
        for (InstructTypeConstant status : InstructTypeConstant.values()) {
            if (status.getValue().equals(value)) {
                return status;
            }
        }
        return null;
    }

}
